<!-- 添加规格类型 -->
<template>
	<view class="panel" v-show="visible">
		<view class="container" :style="{'padding-bottom': safeAreaBottom + 'px'}" :class="{'show': isShow}">
			<view class="header">
				<text class="title">添加规格类型</text>
				<button class="close-btn btn-transition-scale9 iconfont" @click="handleClose()">&#xe60d;</button>
			</view>
			<view class="body">
				<view class="item">
					<text class="tag">型号</text>
				</view>
				<view class="item">
					<text class="tag">重量</text>
				</view>
				<view class="item">
					<text class="tag active">尺寸</text>
				</view>
				<view class="item">
					<text class="tag">型号</text>
				</view>
				<view class="item">
					<text class="tag">重量</text>
				</view>
				<view class="item">
					<text class="tag">尺寸</text>
				</view>
				<view class="item">
					<text class="tag">型号</text>
				</view>
				<view class="item">
					<text class="tag">重量</text>
				</view>
				<view class="item">
					<text class="tag">尺寸</text>
				</view>
			</view>
			<view class="footer" :style="{'padding-bottom': safeAreaBottom === 0? '20rpx': '0rpx'}">
				<button class="btn btn-transition-scale95" @click="handleConfirm()">确 认</button>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref, watch } from 'vue';

	const emits = defineEmits(['update:visible']);

	const visible = defineModel('visible');
	const safeAreaBottom = getApp().globalData.safeAreaBottom; // 底部安全区域高度
	const isShow = ref(false);

	watch(() => visible.value, (value) => {
		if (value) {
			setTimeout(() => {
				isShow.value = true;
			}, 20);
		}
	});

	const handleClose = () => {
		isShow.value = false;
		setTimeout(() => {
			emits('update:visible', false);
		}, 300);
	}

	const handleConfirm = () => {
		handleClose();
	}
</script>

<style lang="scss" scoped>
	.panel {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9999;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.6);
	}

	.container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		background-color: white;
		border-radius: 35rpx 35rpx 0 0;
		padding-top: 50rpx;
		transform: translateY(100%);
		transition: transform 0.3s;

		&.show {
			transform: translateY(0%);
		}

		.header {
			position: relative;
			text-align: center;

			.title {
				font-weight: bold;
				font-size: 36rpx;
				color: #222222;
				font-weight: bold;
			}

			.close-btn {
				position: absolute;
				top: 50%;
				right: 34rpx;
				transform: translateY(-50%);
				font-size: 30rpx;
				color: #999999;
				background-color: transparent;
			}
		}

		.body {
			display: grid;
			grid-template-columns: repeat(3, 1fr);
			row-gap: 46rpx;
			padding: 84rpx 38rpx 56rpx;

			.item {
				display: flex;
				justify-content: center;

				.tag {
					min-width: 134rpx;
					height: 54rpx;
					font-size: 24rpx;
					color: #222222;
					text-align: center;
					line-height: 54rpx;
					background-color: #F2F2F4;
					border-radius: 30rpx;
					padding: 0 30rpx;
					box-sizing: border-box;

					&.active {
						color: #FE3333;
						background-color: #FFDDDD;
					}
				}
			}
		}

		.footer {
			padding: 0 63rpx;

			.btn {
				width: 100%;
				height: 88rpx;
				font-size: 28rpx;
				color: white;
				text-align: center;
				line-height: 88rpx;
				border-radius: 44rpx;
				background-color: #FE3333;
			}
		}
	}
</style>